#ifndef PROGRESSHANDLER_H
#define PROGRESSHANDLER_H

#include <ed_core/global/defs.h>

namespace ed_core
{

/**
 * @brief A common interface to receive progress status of an upcoming task.
 * The ProgressHandler class exposes method that a task can call to report its progress and raise errors.
 * @note: When subclassing ProgressHandler, one should assume that the callback methods are blocking for the upcoming task and thus should not stall the process for too long.
 */
class ED_CORE_API ProgressHandler
{
public:
  virtual ~ProgressHandler() {}

  /**
   * @brief finished is called when the task has finished.
   */
  virtual void finished()=0;

  /**
   * @brief error is called to report an error raised by the upcoming task.
   * @param error contains the error description for display.
   * @note Although it is up to the ProgressHandler to handler error recovery here, it is generally not recommended and should never be required by a task.
   */
  virtual void error(const QString& error)=0;

  /**
   * @brief progress is called to notify the current task's progress.
   * @param step The current step
   * @param max The maximum value that will be reached if the task completes successfully.
   */
  virtual void progress(int step, int max)=0;

  /**
   * @brief message is called to forward a message from the task.
   * @param msg is the message string.
   */
  virtual void message(const QString& msg)=0;
};

} // namespace ed_core

#endif // PROGRESSHANDLER_H
